package by.demchenko.sample.webapp.page.home.share;

import by.demchenko.sample.webapp.page.home.BaseLayout;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;

public class LiteraturePage extends BaseLayout {

    private boolean docVisibility = false;
    private boolean docVisibility2 = false;

    public LiteraturePage() {

        Label docText = new Label("docText");
        docText.setOutputMarkupId(true);
        docText.add(new AttributeModifier("class", new Model<>(docVisibility ? "loginvisible" : "logininvisible")));
        add(docText);

        AjaxLink<Void> link = new AjaxLink<Void>("docLink") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                docVisibility = !docVisibility;
                docText.add(new AttributeModifier("class", new Model<>(docVisibility ? "loginvisible" : "logininvisible")));
                target.add(docText);
            }
        };

        add(link);

        Label docText2 = new Label("docText2");
        docText2.setOutputMarkupId(true);
        docText2.add(new AttributeModifier("class", new Model<>(docVisibility2 ? "loginvisible" : "logininvisible")));
        add(docText2);

        AjaxLink<Void> link2 = new AjaxLink<Void>("docLink2") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                docVisibility2 = !docVisibility2;
                docText2.add(new AttributeModifier("class", new Model<>(docVisibility2 ? "loginvisible" : "logininvisible")));
                target.add(docText2);
            }
        };

        add(link2);
    }
}
